package jp.reflexworks.invoice;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;

import jp.reflexworks.invoice.model.Invoice;
import jp.reflexworks.invoice.model.Order;

public class Instance {

	public static Invoice getUpdateInvoice() {

		Invoice invoice = new Invoice();

		// primary key
		invoice.id = 1;
		
		invoice.revision = 0;
		invoice.invoiceNo = "MNS2009040";
		invoice.companyName = "(株)　PDFサービス";
		invoice.job = "更新プロジェクト";

		return invoice;
		
	}
	
	public static Invoice newInvoice(long i) {
		
		Invoice invoice = new Invoice();
		
		
		invoice.invoiceNo = "MNS200904"+i;
		
		Calendar cal = Calendar.getInstance();
		// 10個おきに日付が変わる
		cal.add(Calendar.DATE,(int) i/10);
		DateFormat dfm = new SimpleDateFormat("yyyy/MM/dd");

		invoice.issuedDate = dfm.format(cal.getTime());
		invoice.companyName = "(株)　クラウドサービス"+i;
		invoice.job = "PDF帳票システム検証プロジェクト"+i;
		
		invoice.orderList = new ArrayList<Order>();
		Order order = new Order();
		order.setInvoiceNo("MNS200904");
		order.seqno = "1";
		order.description = "Relfex iText 機能検証";
		order.quantity = "1式";
		order.unitPrice = "20000";
		order.lineTotal = "20000";
		invoice.orderList.add(order);
		
		order = new Order();
		order.setInvoiceNo("MNS200904"+i);
		order.seqno = "2";
		order.description = "Relfex 技術支援";
		order.quantity = "1式";
		order.unitPrice = "20000";
		order.lineTotal = "20000";
		invoice.orderList.add(order);

		order = new Order();
		order.seqno = "";
		order.description = "";
		order.quantity = "";
		order.unitPrice = "";
		order.lineTotal = "";
		invoice.orderList.add(order);
		order = new Order();
		
		order.seqno = "";
		order.description = "";
		order.quantity = "";
		order.unitPrice = "";
		order.lineTotal = "";
		invoice.orderList.add(order);
		
		order = new Order();
		order.seqno = "";
		order.description = "";
		order.quantity = "";
		order.unitPrice = "";
		order.lineTotal = "";
		invoice.orderList.add(order);
		
		invoice.convertFrom();
		
		invoice.note1 = "①　お支払日：2008年8月末日までにお支払いください。";

		return invoice;
	}


}
